<template>
  <div>
    <el-container>
      <el-header v-color="$store.state.bgColor">
        <div class="record">
          <el-dropdown>
            <span class="el-dropdown-link" @click="changecolor">
              切换主题<i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>随机切换</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <el-dropdown @command="handleCommand">
            <span class="el-dropdown-link">
              admin<i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="quit">退出</el-dropdown-item>
              <el-dropdown-item command="alte">修改</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-header>
      <el-container>
        <el-aside width="auto" v-color="$store.state.bgColor">
          <el-radio-group v-model="isCollapse" style="margin-bottom: 20px">
            <img
              v-show="!isCollapse"
              src="../../assets/作业资料/pic/logo/white@3x.png"
              class="asd"
              @click="isCollapse = true"
            />
            <i
              class="el-icon-s-unfold afo"
              v-show="isCollapse"
              @click="isCollapse = false"
            ></i>
          </el-radio-group>
          <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            :background-color="$store.state.bgColor"
            :collapse="isCollapse"
            text-color="#fff"
            active-text-color="#fff"
            
            router
          >
            <el-submenu
              :index="item.id + ''"
              v-for="(item, id) in list"
              :key="item.id"
            >
              <template slot="title">
                <i :class="item.icon"></i>
                <span>{{ item.title }}</span>
              </template>
              <el-menu-item-group>
                <el-menu-item
                  :index="item.url"
                  v-for="item in xtlist"
                  :key="item.id"
                  >{{ item.title }}</el-menu-item
                >
              </el-menu-item-group>
            </el-submenu>
            <el-submenu
              :index="item.id + ''"
              v-for="(item, id) in ilst"
              :key="item.id"
            >
              <template slot="title">
                <i :class="item.icon"></i>
                <span>{{ item.title }}</span>
              </template>
              <el-menu-item-group>
                <el-menu-item
                  :index="item.url"
                  v-for="item in getlist"
                  :key="item.id"
                  >{{ item.title }}</el-menu-item
                >
              </el-menu-item-group>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main><router-view></router-view></el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "",
  components: {},
  data() {
    return {
      list: [],
      xtlist: [],
      ilst: [],
      getlist: [],
      isCollapse: false,
    };
  },
  created() {},
  mounted() {
    this.$api.reqGetCate().then(
      (res) => (
        console.log(res),
        (this.list = res.data.list.filter((item) => {
          return item.id == 1;
          console.log(item);
        })),
        (this.xtlist = res.data.list.filter((item) => {
          return item.pid == 1;
          console.log(item);
        })),
        (this.ilst = res.data.list.filter((item) => {
          return item.id == 8;
          console.log(item);
        })),
        (this.getlist = res.data.list.filter((item) => {
          return item.pid == 8;
          console.log(item);
        }))
      )
    );
  },
  methods: {
    handleCommand(command) {
      console.log(command);
      command == "quit" ? this.loginquit() : this.loginalte();
    },
    loginquit() {
      this.$confirm("确认返回")
        .then((res) => {
          localStorage.removeItem("token");
          this.$router.replace("/login");
        })
        .catch((_) => {});
    },
    loginalte() {},
    changecolor() {
      this.$store.commit("changecolor");
    },
  },
};
</script>
<style scoped lang="scss">
.el-header,
.el-footer {
  background-color: #ff694d;
  color: white;
  line-height: 60px;
  .record {
    display: flex;
    justify-content: space-around;
  }
}

.el-aside {
  background-color: #ff694d;
  color: #333;
  text-align: center;
  height: 100vh;
}
.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
}
.asd {
  width: 130px;
  height: 35px;
  margin: 20px 32px;
  cursor: pointer;
}
.afo {
  cursor: pointer;
  color: white;
  font-size: 50px;
}
</style>
